<template>
  <view class="culture">
    <!-- <view class="culture-swiper">
      <BannerSwiper :List="list" />
    </view> -->

    <view class="culture-card">
      <activity-card
        v-for="item in datalist"
        :key="item.id"
        class="card"
        :data="item"
      />
    </view>
    <view v-if="morebtn" class="bottom" @tap="loadMore">加载更多>></view>
  </view>
</template>

<script>
import "./index.scss";
import Taro, { getCurrentInstance } from "@tarojs/taro";
import BannerSwiper from "../../components/bannerswiper/index";
import activityCard from "../../components/activityCard/index";
import img1 from "../../assets/image/build1.png";
import requset from "../../utils/request"

export default {
  //   props: {
  //       'BannerSwiper',
  //   },
  components: {
    BannerSwiper: BannerSwiper,
    "activity-card": activityCard,
  },
  data() {
    return {
      typeId:'',
      list: [{ image: img1 }, { image: img1 }, { image: img1 }],
      morebtn:true,
      page: {
        row_limit: 10, 
        p: 1, 
      },
      datalist: [],
    };
  },
  created() {
    console.log(getCurrentInstance().router.params.typeId, "23342");
    this.typeId=getCurrentInstance().router.params.typeId
    this.getArticlesList(this.page)
  },
  methods: {

     getArticlesList(page) {
       console.log(page)
      requset("get", "/api/rest/articles.htm", {
        ...page,
        q_category_id:this.typeId
      }).then((res) => {
        console.log(res._list,'44');
        if(this.typeId){
          wx.setNavigationBarTitle({
          title: res._list[0].category_id.name,
        });
        }
        this.page.p=res._page.page_current
        // this.menulist = res._list
        this.datalist = [...this.datalist,...res._list];
        console.log( res._page.page_count, res._page.page_current)
        if( res._page.page_count<=res._page.page_current)this.morebtn = false
        // _id title face_image_id
      });
    },
    loadMore(){
      const newPage = {
        row_limit: 10, 
        p: this.page.p+1, 
      }
      this.getArticlesList(newPage)
    }
  },
};
</script>

<style>
.culture-swiper {
  width: 100%;
  height: 300rpx;
}
</style>